package J_exercise;

import java.util.Scanner;

public class J_ex31_40 {

	public static void main(String[] args) {
		
		//31번문제 : 신용카드 6자리 입력받아 카드 정보 출력 및 저장
		
		System.out.println("신용카드 숫자 6자리를 적어주세요\n"+
							"카드정보를 알려드립니다.");
		Scanner a1=new Scanner(System.in);
		int number=a1.nextInt();
		String cardname=CardService.CardInfo(number);
		
		CardVO mycard=new CardVO();
		mycard.setCardNumber(number);
		mycard.setCardName(cardname);
		System.out.println("\n카드번호="+mycard.getCardNumber()
							+"\n카드이름="+mycard.getCardName());
		
		//32 주민등록번호 유효성 검사
		/*
		Scanner j= new Scanner(System.in);
		long jumin=j.nextLong();
		System.out.println(JuminService.effectiveness(jumin));
		*/
		//35 
		int money=183200;
		int price=13200;
		
		System.out.println(price+"입니다.");
		System.out.println(money+"받았습니다.");
		ChargeService.charge(money, price);
		
	}//end of main
		
}		
		
		
		
class CardVO
{
	private int cardnumber;
	private String cardname;
	//생성자
	public CardVO() {}
	public CardVO(int number,String cardname) {}

	public void setCardNumber(int cardnumber)
	{this.cardnumber=cardnumber;}
	public void setCardName(String cardname)
	{this.cardname=cardname;}
	public int getCardNumber(){return this.cardnumber;}
	public String getCardName(){return this.cardname;}
	
}
class CardService
{
	public static String CardInfo(int number)
	{
		String cardname="";
		if(number/10000==35)
		{
			System.out.println("35(JCB카드)");
			if(number==356317)cardname="NH농협카드";
			else if (number==356901) cardname="신한카드";
			else  cardname="KB국민카드";	
		}
		else if(number/100000==4)
		{
			System.out.println("4(비자카드");
			if(number==404825) cardname="비씨카드";
			else if(number==438676) cardname="신한카드";
			else cardname="국민은행";
		}
		else if(number/100000==5)
		{
			System.out.println("5(마스타카드,maestro)");
			if(number==515594) cardname="신한카드";
			else if(number==524353) cardname="외환카드";
			else cardname="국민은행";
			
		}
		return cardname;
		
	}
}
class JuminVO
{
	private int price;//가격
	private int money;//받은금액
	
	public void setMoney(int money,int price)
	{ this.money=money; this.price=price;}
	public int getPrice(int price)
	{return price;}
	
 
	
}
class JuminService
{
	public static String effectiveness(long jumin)
	{
		long num13=jumin%10;
		
		int total=0;

//		System.out.println(Math.pow(10, 12));
		for(long div=1000000000000L,prime=2; 
				div>=10L;div/=10,++prime)
		{
			if(prime>9) {prime=2;}
			int key;
			key=(int)(jumin/div);
			total=total+(key*(int)prime);
			if(key>0) jumin=jumin%(key*div);
		}
	
		if(11-(total%11)==num13)		
			return "정상";
		else 
			return "비정상";
		
	}
	
}

class ChargeService
{
	public static void charge(int money,int price)
	{
		int charge= money-price;
		int[] charges={0,0,0,0,0,0,0,0,0};
		int[] moneys={0,50000,10000,5000,1000,500,100,50,10};
		
		System.out.println("잔돈"+charge);
		
		for(int i=1;i<=8;i++)
		{
		  	charges[i]=charge/moneys[i];
		  	charge%=moneys[i];
		  	if(charges[i]!=0)
		  	System.out.println(moneys[i]+"원"+charges[i]+"장");
		  	
		}
		
		
		
		
	}
}
